<?php
if ( !defined('WP_PLUGIN_URL') )
define( 'WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins' );                           
define('IBAPITHEMESET_BASENAME', plugin_basename(__FILE__));                        
define('IBAPITHEMESET_BASEFOLDER', plugin_basename(dirname(__FILE__)));    
define('IBAPITHEMESET_FILENAME', str_replace(IBAPITHEMESET_BASEFOLDER.'/', '', plugin_basename(__FILE__)));

// 注册插件
register_activation_hook(__FILE__, 'ibapithemeset_set_options');


/**
 * 初始化选项的值
 */
function ibapithemeset_set_options() {
      $this_theme_name = '仿Tencent CDC主题'; //当前主题
	  $active_plugin = 'true'; //插件内部开关
	 $slug_plugin = 'false'; //cos_slug_translator开关
    $theme_keywords = ''; //设置关键字默认值为空
    $theme_desciption = ''; //设置描述默认值为空
    $theme_contentlimit = '110'; //设置single页内容截断为110中文字
    $options = array('theme_keywords'=>$theme_keywords, 'theme_description'=>$theme_description, 'theme_contentlimits'=>$theme_contentlimit, 'active_plugin'=>$active_plugin, 'slug_plugin'=>$slug_plugin); //定义数组
    add_option('ibapithemeset_options', $options, '', 'yes'); //添加option
}

/**
 * 获取选项
 */
function ibapithemeset_get_options(){
    return get_option('ibapithemeset_options', TRUE);
}
// 添加Filter
add_filter('ibapithemeset_message', 'wptexturize');


if (is_admin()){ //为管理员时加载设置页面
    require 'ibapithemeset-admin.php';
    add_action('admin_menu', 'ibapithemeset_add_setting_page');

}
else{ //非管理员时加载
    require 'ibapithemeset-insert.php'; //装载 SEO Function 文件
 	add_action('wp_head', 'ibapithemeset_insert_seo_setting'); //添加 Action
}

//加载cos_slug_translator

require 'cosslugtranslator.php'; //装载 Cos_Slub_Translator 文件
?>